$(function(){
	var car_number = echarts.init(document.getElementById('car_number'));
	option = {
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b}: {c} ({d}%)"
		},
		legend: {
			orient: 'vertical',
			x: 'left',
			data: ['关联车辆', '未关联车辆']
		},
		series: [{
			name: '订单数量',
			type: 'pie',
			radius: ['50%', '70%'],
			avoidLabelOverlap: false,
			label: {
				normal: {
					show: false,
					position: 'center'
				},
				emphasis: {
					show: true,
					textStyle: {
						fontSize: '15',
						fontWeight: 'bold'
					}
				}
			},
			labelLine: {
				normal: {
					show: false
				}
			},
			data: [{
					value: 665,
					name: '关联车辆'
				},
				{
					value: 335,
					name: '未关联车辆'
				}
			]
		}]
	};
	car_number.setOption(option);
	
	var fuelconsumption = echarts.init(document.getElementById('fuelconsumption'));
        optionfuel = {
            tooltip: {
                trigger: 'axis'
            },
            grid: {
                top: '3%',
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: [{
                type: 'category',
                boundaryGap: false,
                data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
            }],
            yAxis: [{
                type: 'value'
            }],
            textStyle: {
                color: '#838FA1'
            },
            series: [{
                name: '邮件营销',
                type: 'line',
                stack: '总量',
                areaStyle: { normal: {} },
                data: [120, 132, 101, 134, 90],
                itemStyle: { 
                    normal: {
                        color: '#1cabdb',
                        borderColor: '#1cabdb',
                        borderWidth: '2',
                        borderType: 'solid',
                        opacity: '1'
                    },
                    emphasis: {

                    }
                }
            }]
        };

        fuelconsumption.setOption(optionfuel);
        $('.service').on('click', function() {
        	if($(this).closest('.outline').data('number')){
        		choosecar("{:url('service/index',['op'=>'search'])}?number="+$(this).closest('.outline').data('number'))
        	}else if($(this).closest('.outline').data('company')){
        		
        		choosecar("{:url('service/index',['op'=>'search'])}?company="+$(this).closest('.outline').data('company'))
        	}else{
        		choosecar("{:url('service/index',['op'=>'search'])}")
        	}
			
		});
		$('.survey').on('click', function() {
			if($(this).closest('.outline').data('number')){
        		choosecar("{:url('survey/index',['op'=>'search'])}?number="+$(this).closest('.outline').data('number'))
        	}else if($(this).closest('.outline').data('company')){
        		choosecar("{:url('survey/index',['op'=>'search'])}?company="+$(this).closest('.outline').data('company'))
        	}else{
        		choosecar("{:url('survey/index',['op'=>'search'])}")
        	}
		});
		$('.refuel').on('click', function() {
			if($(this).closest('.outline').data('number')){
        		choosecar("{:url('refuel/index',['op'=>'search'])}?number="+$(this).closest('.outline').data('number'))
        	}else if($(this).closest('.outline').data('company')){
        		choosecar("{:url('refuel/index',['op'=>'search'])}?company="+$(this).closest('.outline').data('company'))
        	}else{
        		choosecar("{:url('refuel/index',['op'=>'search'])}")
        	}
		});
		$('.insure').on('click', function() {
			if($(this).closest('.outline').data('number')){
        		choosecar("{:url('insure/index',['op'=>'search'])}?number="+$(this).closest('.outline').data('number'))
        	}else if($(this).closest('.outline').data('company')){
        		choosecar("{:url('insure/index',['op'=>'search'])}?company="+$(this).closest('.outline').data('company'))
        	}else{
        		choosecar("{:url('insure/index',['op'=>'search'])}")
        	}
		});
})
